package cn.tedu.yl.news_bulletin.service.impl;

import cn.tedu.yl.cost.pojo.dto.CostQuery;
import cn.tedu.yl.cost.pojo.dto.CostSaveParam;
import cn.tedu.yl.cost.pojo.entity.Cost;
import cn.tedu.yl.cost.pojo.vo.CostVO;
import cn.tedu.yl.news_bulletin.mapper.News_bulletinMapper;
import cn.tedu.yl.news_bulletin.pojo.dto.News_bulletinParam;
import cn.tedu.yl.news_bulletin.pojo.dto.News_bulletinQuery;
import cn.tedu.yl.news_bulletin.pojo.entity.news_bulletin;
import cn.tedu.yl.news_bulletin.pojo.vo.news_bulletinVO;
import cn.tedu.yl.news_bulletin.service.News_bulletinService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class news_bulletinImpl implements News_bulletinService{
    @Autowired
    private News_bulletinMapper news_bulletinMapper;

    @Override
    public List<news_bulletinVO> select(News_bulletinQuery newsBulletinQuery) {

        return news_bulletinMapper.selectNews(newsBulletinQuery);
    }

    @Override
    public void save(News_bulletinParam news_bulletinParam) {
        news_bulletin news_bulletin=new news_bulletin();
        BeanUtils.copyProperties(news_bulletinParam,news_bulletin);
        if (news_bulletin.getId()==null){
            news_bulletinMapper.insertCostNews(news_bulletin);
        }
        else {
            news_bulletinMapper.updateCostNews(news_bulletin);
        }
    }

}
